package cn.gson.fengboot.model.service;

import cn.gson.fengboot.model.dao.LwxcbDao;
import cn.gson.fengboot.model.dao.LwxzbDao;
import cn.gson.fengboot.model.mapper.LwxzbMapper;
import cn.gson.fengboot.model.pojos.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class LwxzbService {

    @Autowired
    LwxzbDao lwxzbDao;
    @Autowired
    LwxcbDao lwxcbDao;
    @Autowired
    LwxzbMapper lwxzbMapper;

    //查询工单信息
    public List<Lwxzb> wxzbcx(String shijian,String lsh){
        return lwxzbMapper.wxzbcx(shijian,lsh);
    }

    //维修单号
    public  String danhao(){
       return lwxzbDao.wxdanhao() ;
    }

    //根据客户查询联系人
    public List<TfylinkmanForm> lxr(Integer khname){
        return lwxzbMapper.lxr(khname);
    }

    //根据客户查询联系人
    public List<Zorder> ddcx(Integer ddname){
        return lwxzbMapper.ddcx(ddname);
    }

    //根据客户查询联系人
    public List<Zorderdetails> cpcx( Integer cpname){
        return lwxzbMapper.cpcx(cpname);
    };

    //新增维修主从表
    @Transactional(transactionManager = "transactionManager")
    public  void addwxd(Lwxzb lwxzb){
        System.err.println(lwxzb.getProdetailId());
        lwxzbDao.save(lwxzb);
        lwxzb.getGdxbId().forEach(v->{
         v.setLwxzb(lwxzb);
        });
        lwxcbDao.saveAll(lwxzb.getGdxbId());
    }

    //根据工单进度查询-----待检测
    public List<Lwxzb> selectdaiJianCe(){
        return  lwxzbMapper.daiJianCe();
    };

    //根据工单进度查询-----待与客户确认
    public List<Lwxzb> selectdaiYvKeHuQueRen(){
        return  lwxzbMapper.daiYvKeHuQueRen();
    };

    //根据工单进度查询-----待维修
    public List<Lwxzb> selectdaiWeiXiu(){
        return  lwxzbMapper.daiWeiXiu();
    };

    //根据工单进度查询-----维修中
    public List<Lwxzb> selectweiXiuZhong(){
        return  lwxzbMapper.weiXiuZhong();
    };

    //根据工单进度查询-----修理完成
    public List<Lwxzb> selectxiuLiWanCheng(){
        return  lwxzbMapper.xiuLiWanCheng();
    };

    //根据工单进度查询-----待交付
    public List<Lwxzb> selectdaiJiaoFu(){
        return  lwxzbMapper.daiJiaoFu();
    };

    //根据工单进度查询-----已交付
    public List<Lwxzb> selectyiJiaoFu(){
        return  lwxzbMapper.yiJiaoFu();
    };

    //根据工单进度查询-----已完成
    public List<Lwxzb> selectyiWanCheng(){
        return  lwxzbMapper.yiWanCheng();
    };

    //查询售后部门员工
    public List<QempFrom> shohouyg(){
        return lwxzbMapper.shohouyg();
    }

    //查询售后部门员工
    public List<QdepFrom> shohoubm(){
        return lwxzbMapper.shohoubm();
    }

    //<!--谭方圆=>客户合并的维修工单查询-->
    public List<Lwxzb> tfyweixiu(Integer id1, Integer id2){
        return lwxzbMapper.tfyweixiu(id1,id2);
    }

}
